package com.sky.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 自定义任务类
 */
@Slf4j
@Component

public class MyTask {

    @Autowired

    /**
     * 定时任务，每5秒触发
     */
    @Scheduled(cron = "0/5 * * * * ?")
    public void  executeTask(){
        //现在时间开始
        log.info("定时任务时间 {}" , new Date());

    }

}
